


let oul = document.querySelector("ul");
let oli = document.querySelectorAll("li");

const xhr = new XMLHttpRequest();

xhr.open("get","http://chst.vip:1234/api/getsitenav",true);

xhr.send(null);

xhr.onreadystatechange = function(){
    if(xhr.readyState === 4){
        if(xhr.status === 200){
            let res = JSON.parse(xhr.responseText);
            // console.log(res.result[0]);
            console.log(res);
            // let regExp = /(?<=imgurl=)[^'"]*/;
            let ele = "";
            res.result.forEach(item => {
                // console.log(item);
                // var img = regExp.exec(item.productImg)[0];
                // var img = item.productImg;
                // console.log(img);
                ele += `<li>
                            <a href="${item.navHref}">
                                <img src="${item.navImg}" alt="">
                                <span>${item.navTitle}</span>
                            </a>
                        </li> `
                
                
                // ` <li id=${item.productId}>
                //             <a href="./pages/xq.html?productid=${item.productId}">
                //                 <img src="${img}" alt="">
                //                 <p>
                //                     ${item.productName}
                //                     <span>${item.productPinkage}</span>
                //                 </p>
                //                 <span>${item.productFrom}|${item.productTime}</span>
                //                 <span>${item.productComCount}</span>
                //             </a>
                //         </li>`;
            });
            oul.innerHTML = ele;
        }
    }
}